package com.fpx.xms.api.base.model;

/**
 * 返回结果模型对象
 * @author shiw
 *         2014年11月20日
 */
public class Result {

    /** 状态码0:失败， 1：正常 */
    private int status = ResultStatusEnum.SUCCESS.getCode();

    /** 消息 */
    private String msg;

    /** 业务数据 */
    private Object data;

    public Result() {
    }

    public Result(String msg) {
        this.msg = msg;
    }

    public Result(Object data) {
        this.data = data;
    }

    public Result(int status, String msg) {
        this(msg);
        this.status = status;
    }

    /**
     * 构建错误结果模型
     * @return
     */
    public static Result error() {
        return new Result(ResultStatusEnum.FAILURE.getCode(), "");
    }

    /**
     * 构建错误结果模型
     * @param msg
     * @return
     */
    public static Result error(String msg) {
        return new Result(ResultStatusEnum.FAILURE.getCode(), msg);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
